package com.web.zsqqimengzhixing.service.impl;

import com.web.zsqqimengzhixing.mapper.UserprofileMapper;
import com.web.zsqqimengzhixing.pojo.Userprofile;
import com.web.zsqqimengzhixing.service.UserprofileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserprofileServiceImpl implements UserprofileService {
    @Autowired
    private  UserprofileMapper userprofileMapper;


    /**
     * 查找或添加用户
     *
     * @param mobile
     */
    @Override
    public void login(String mobile) {
        Userprofile e = userprofileMapper.selectByMobile(mobile);
        //如果没有该用户就添加
        if (e == null) {
            e = new Userprofile();
            e.setMobile(mobile);
            e.setUsername("Steve");
            userprofileMapper.insert(e);
        }
    }
    /**
     * 根据手机号查询个人信息
     *
     * @return
     */
    @Override
    public Userprofile select(String mobile) {
        Userprofile e = userprofileMapper.selectByMobile(mobile);
        System.out.println(e);
        return e;
    }
}
